package com.itboye.jinpuyiyuan.activity.home.hospitalserver;

import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;

import com.itboye.jinpuyiyuan.R;
import com.itboye.jinpuyiyuan.adapter.TestServerOrderAdapter;
import com.itboye.jinpuyiyuan.base.BaseActivity;
import com.itboye.jinpuyiyuan.bean.TestServerOrder;

import java.util.ArrayList;

/**
 * Created by Administrator on 2017/12/15 0015.
 */

public class HospitalServerActivity extends BaseActivity {
    //title
    private ImageView leftImg,rightImg;
    private TextView leftTv,tvTitle;
    private RelativeLayout rlLeft,toobar;

    private Button prepayTv,dayListTv;
    private TextView totalTv;
    private LinearLayout prepayLL;
    private TableLayout dayListTl;
    private ArrayList<String> list;
//    private MyAdapter myAdapter;
    @Override
    protected void onCreate(Bundle arg0) {
        super.onCreate(arg0);
        setContentView(R.layout.activity_hospitalserver);
        leftTv.setVisibility(View.GONE);
        rightImg.setVisibility(View.GONE);
        tvTitle.setText("住院服务");
        list=new ArrayList<>();
        for (int i=0;i<5;i++){
            TableRow tableRow = new TableRow(this);
            TableRow.LayoutParams params=new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            params.weight=1;
            for (int j=0;j<4;j++){
                TextView textView = new TextView(this);
                textView.setText("金额");
                textView.setGravity(Gravity.CENTER);
                textView.setPadding(0,16,0,16);
                textView.setLayoutParams(params);
                textView.setBackgroundDrawable(getResources().getDrawable(R.drawable.item_tableview_bg));
                tableRow.addView(textView);
            }
            dayListTl.addView(tableRow);
        }


    }
    @Override
    public void onClick(View view) {
        super.onClick(view);
        switch (view.getId()){
            case R.id.rlLeft:
            case R.id.leftImg:
                this.finish();
                break;

            case R.id.prepayTv:
                cancleTableState();
                prepayLL.setVisibility(View.VISIBLE);
                prepayTv.setBackgroundDrawable(getResources().getDrawable(R.drawable.login_corner_bluesolid_btn));
                prepayTv.setTextColor(getResources().getColor(R.color.white));
                totalTv.setText("前往支付");
                break;

            case R.id.dayListTv:
                cancleTableState();
                dayListTl.setVisibility(View.VISIBLE);
                dayListTv.setBackgroundDrawable(getResources().getDrawable(R.drawable.login_corner_bluesolid_btn));
                dayListTv.setTextColor(getResources().getColor(R.color.white));
                totalTv.setText("合计");
                break;

        }
    }

    public void cancleTableState(){
        dayListTl.setVisibility(View.GONE);
        prepayLL.setVisibility(View.GONE);
         prepayTv.setBackgroundDrawable(getResources().getDrawable(R.drawable.login_corner_blueedge));
         prepayTv.setTextColor(getResources().getColor(R.color.title_blue));
         dayListTv.setBackgroundDrawable(getResources().getDrawable(R.drawable.login_corner_blueedge));
         dayListTv.setTextColor(getResources().getColor(R.color.title_blue));

    }

//    class MyAdapter extends BaseAdapter{
//
//        private ArrayList<String> list;
//        private Context context;
//        private LayoutInflater inflater;
//        public  MyAdapter(Context context,ArrayList<String> list){
//
//            this.list=list;
//            this.context=context;
//            inflater=LayoutInflater.from(context);
//        }
//        @Override
//        public int getCount() {
//            return list.size();
//        }
//
//        @Override
//        public Object getItem(int position) {
//            return list.get(position);
//        }
//
//        @Override
//        public long getItemId(int position) {
//            return position;
//        }
//
//        @Override
//        public View getView(int position, View convertView, ViewGroup parent) {
//            MyViewHolder myViewHolder;
//            if (convertView==null){
//                myViewHolder=new MyViewHolder();
//                convertView=inflater.inflate(R.layout.item_hospitalserver_gridelist,parent,false);
//                myViewHolder.tableItemTv=convertView.findViewById(R.id.tableItemTv);
//                convertView.setTag(myViewHolder);
//            }else {
//                myViewHolder= (MyViewHolder) convertView.getTag();
//            }
//            myViewHolder.tableItemTv.setText(list.get(position));
//
//
//            return convertView;
//        }
//
//        class MyViewHolder{
//            TextView tableItemTv;
//        }
//    }
}
